                                                                                                                

// 导入ZtzbProcessEmployee
$().ready(function () {

    layui.use('upload', function () {
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#btnUpload', //绑定元素
            // url: '/common/sysFile/upload?type=98&contractId='+$('#device_id').val(), //上传接口
            // url: '/cm/cmContract/upload2?type=98&contractId='+$('#contractId').val(), //上传接口
            url: '/ztzb/ztzbProcessEmployee/importZtzbProcessEmployeeData', //上传接口
            size: 50000,
            accept: 'file',
            exts: 'xls|xlsx',
            done: function (r) {
                if (r.code == 0) {
                    layer.msg("导入成功");
                    reLoad();
                }
            },
            error: function (r) {
                layer.msg("导入失败");
            }
        });
    });
});

// downLoadTemplateZtzbProcessEmployee
function downLoadTemplateZtzbProcessEmployee() {
    var url = "/ztzb/ztzbProcessEmployee/downLoadZtzbProcessEmployeeData"; //添加 href 属性
    downBlob(url)
}

// 模拟导出方法
function downBlob(url) {
    var xhr = new XMLHttpRequest();
    xhr.open('GET', url, true);    // 也可用POST方式
    xhr.responseType = "blob";
    // $.modal.loading("正在导出，请稍后...")
    xhr.onload = function () {
        if (this.status === 200) {
            var blob = this.response;
            if (navigator.msSaveBlob == null) {
                var a = document.createElement('a');
                var headerName = xhr.getResponseHeader("Content-disposition");
                a.download = decodeURIComponent(headerName).substring(20);
                a.href = URL.createObjectURL(blob);
                $("body").append(a);    // 修复firefox中无法触发click
                a.click();
                URL.revokeObjectURL(a.href);
                $(a).remove();
            } else {
                navigator.msSaveBlob(blob, decodeURIComponent(headerName).substring(20));
            }
        }
        // $.modal.closeLoading()
    };
    xhr.send()
}